 package handling.login.handler;

 import client.MapleCharacter;
 import client.MapleCharacterUtil;
 import client.MapleClient;
 import client.inventory.Item;
 import client.inventory.MapleInventory;
 import client.inventory.MapleInventoryType;
 import constants.ServerConstants;
 import handling.login.JobType;
 import handling.login.LoginInformationProvider;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import server.MapleItemInformationProvider;
 import server.quest.MapleQuest;
 import tools.data.input.LittleEndianAccessor;
 import tools.packet.LoginPacket;










 public class CreateCharHandler
 {
/*  30 */   private static final Logger log = LogManager.getLogger(CreateCharHandler.class);

   public static void getCreatCharAuth(LittleEndianAccessor slea, MapleClient c) {
/*  33 */     c.announce(LoginPacket.getCreatCharAuth(c));
   }

   public static void handlePacket(LittleEndianAccessor slea, MapleClient c) {
/*  37 */     if (!c.isLoggedIn()) {
/*  38 */       c.getSession().close();








       return;
     }







/*  56 */     int faceMark = 0;
/*  57 */     int cap = 0;

/*  59 */     int cape = 0;
/*  60 */     int bottom = 0;

/*  62 */     int glove = 0;

/*  64 */     int shield = 0;


/*  67 */     String name = slea.readMapleAsciiString();
/*  68 */     int keymode = slea.readInt();
/*  69 */     if (keymode != 0 && keymode != 1) {
/*  70 */       System.out.println("创建角色错误 键盘模式错误 当前模式: " + keymode);
/*  71 */       c.announce(LoginPacket.charNameResponse(name, (byte)3));
       return;
     }
/*  74 */     slea.readInt();
/*  75 */     int job_type = slea.readInt();
/*  76 */     JobType job = JobType.getByType(job_type);
/*  77 */     if (job == null) {
/*  78 */       System.out.println("创建角色错误 没有找到该职业类型的数据 当前职业类型: " + job_type);




       return;
     }



/*  88 */     short subcategory = slea.readShort();
/*  89 */     JobType jobType = JobType.getByType(job_type);
/*  90 */     byte gender = slea.readByte();
/*  91 */     byte skin = slea.readByte();
/*  92 */     byte hairColor = slea.readByte();
/*  93 */     int face = slea.readInt();
/*  94 */     int hair = slea.readInt();
/*  95 */     if (job.faceMark) {
/*  96 */       faceMark = slea.readInt();
     }
/*  98 */     if (job == JobType.林之灵) {
/*  99 */       slea.readInt();
/* 100 */       slea.readInt();
/* 101 */     } else if (job == JobType.剑豪 || job == JobType.阴阳师 || job.cap) {
/* 102 */       cap = slea.readInt();
     }
/* 104 */     int top = slea.readInt();
/* 105 */     if (job.cape) {
/* 106 */       cape = slea.readInt();
     }

/* 109 */     if (top / 10000 == 104 || job.bottom) {
/* 110 */       bottom = slea.readInt();
     }
/* 112 */     int shoes = slea.readInt();
/* 113 */     if (job == JobType.剑豪 || job == JobType.阴阳师) {
/* 114 */       glove = slea.readInt();
     }
/* 116 */     int weapon = slea.readInt();
/* 117 */     if (slea.available() >= 4L) {
/* 118 */       shield = slea.readInt();
     }
/* 120 */     if (ServerConstants.isShowPacket()) {
/* 121 */       log.info("\r\n名字: " + name + "\r\n职业: " + job_type + "\r\n性别: " + gender + "\r\n皮肤: " + skin + "\r\n头发: " + hairColor + "\r\n脸型: " + face + "\r\n发型: " + hair + "\r\n脸饰: " + faceMark + "\r\n帽子: " + cap + "\r\n上衣: " + top + "\r\n裤子: " + bottom + "\r\n鞋子: " + shoes + "\r\n手套: " + glove + "\r\n武器: " + weapon + "\r\n盾牌: " + shield + "\r\n");
     }















/* 138 */     MapleItemInformationProvider li = MapleItemInformationProvider.getInstance();
/* 139 */     int[] items = { top, bottom, cape, shoes, weapon, shield };
/* 140 */     for (int i : items) {
/* 141 */       if (!LoginInformationProvider.getInstance().isEligibleItem(i)) {
/* 142 */         log.info("[作弊] 新建角色装备检测失败 名字: " + name + " 职业: " + job_type + " 道具ID: " + i + " - " + li.getName(i));
/* 143 */         c.announce(LoginPacket.charNameResponse(name, (byte)3));

         return;
       }
     }
/* 148 */     MapleCharacter newchar = MapleCharacter.getDefault(c, jobType);
/* 149 */     newchar.setWorld((byte)c.getWorld());
/* 150 */     newchar.setFace(face);
/* 151 */     newchar.setHair(hair);
/* 152 */     newchar.setGender(gender);
/* 153 */     newchar.setName(name);
/* 154 */     newchar.setSkinColor(skin);
/* 155 */     newchar.setDecorate(faceMark);
/* 156 */     newchar.setGmLevel(c.getGmLevel());
/* 157 */     if (job == JobType.神之子) {
/* 158 */       newchar.setLevel((short)100);
/* 159 */       (newchar.getStat()).str = 518;
/* 160 */       (newchar.getStat()).dex = 4;
/* 161 */       (newchar.getStat()).luk = 4;
/* 162 */       (newchar.getStat()).int_ = 4;
/* 163 */       (newchar.getStat()).maxhp = 6485;
/* 164 */       (newchar.getStat()).hp = 6485;
/* 165 */       (newchar.getStat()).maxmp = 100;
/* 166 */       (newchar.getStat()).mp = 100;
/* 167 */       newchar.setRemainingSp(3, 0);
/* 168 */       newchar.setRemainingSp(3, 1);
/* 169 */     } else if (job == JobType.林之灵) {
/* 170 */       (newchar.getStat()).maxhp = 570;
/* 171 */       (newchar.getStat()).hp = 570;
/* 172 */       (newchar.getStat()).maxmp = 270;
/* 173 */       (newchar.getStat()).mp = 270;
/* 174 */       newchar.setRemainingAp((short)45);
/* 175 */       newchar.setRemainingSp(3, 0);
/* 176 */       newchar.updateInfoQuest(59300, "bTail=1;bEar=1;TailID=5010119;EarID=5010116", false);
/* 177 */     } else if (job == JobType.超能力者) {
/* 178 */       (newchar.getStat()).maxhp = 570;
/* 179 */       (newchar.getStat()).hp = 570;
/* 180 */       (newchar.getStat()).maxmp = 0;
/* 181 */       (newchar.getStat()).mp = 0;
/* 182 */       newchar.setRemainingAp((short)45);
/* 183 */     } else if (job == JobType.恶魔猎手) {
/* 184 */       (newchar.getStat()).mp = 10;
/* 185 */       (newchar.getStat()).maxmp = 10;
     }


/* 189 */     switch (job) {
       case 林之灵:
       case 超能力者:
       case 夜光:
       case 狂龙:
       case 萝莉:
       case 尖兵:
       case 隐月:
       case 剑豪:
       case 阴阳师:
       case 米哈尔:
       case 幻影:
       case 恶魔猎手:
       case 御剑骑士:
/* 203 */         newchar.setLevel((short)10);
/* 204 */         newchar.setRemainingAp((short)50);
         break;
     }

/* 208 */     MapleInventory equipedIv = newchar.getInventory(MapleInventoryType.EQUIPPED);

/* 210 */     int[][] equips = { { cap, -1 }, { top, -5 }, { bottom, -6 }, { shoes, -7 }, { glove, -8 }, { cape, -9 }, { weapon, -11 }, { shield, -10 } };








/* 219 */     for (int[] i : equips) {
/* 220 */       if (i[0] > 0) {
/* 221 */         Item item = li.getEquipById(i[0]);
/* 222 */         item.setPosition((short)(byte)i[1]);
/* 223 */         item.setGMLog("角色创建");
/* 224 */         equipedIv.addFromDB(item);
       }
     }

/* 228 */     newchar.getInventory(MapleInventoryType.USE).addItem(new Item(2000013, (short)0, (short)100, (short)0));
/* 229 */     newchar.getInventory(MapleInventoryType.USE).addItem(new Item(2000014, (short)0, (short)100, (short)0));

/* 231 */     int[][] guidebooks = { { 4161001, 0 }, { 4161047, 1 }, { 4161048, 2000 }, { 4161052, 2001 }, { 4161054, 3 }, { 4161079, 2002 } };
/* 232 */     int guidebook = 0;
/* 233 */     for (int[] i : guidebooks) {
/* 234 */       if (newchar.getJob() == i[1]) {
/* 235 */         guidebook = i[0];
/* 236 */       } else if (newchar.getJob() / 1000 == i[1]) {
/* 237 */         guidebook = i[0];
       }
     }
/* 240 */     if (guidebook > 0) {
/* 241 */       newchar.getInventory(MapleInventoryType.ETC).addItem(new Item(guidebook, (short)0, (short)1, (short)0));
     }

/* 244 */     if (job.equals(JobType.骑士团)) {
/* 245 */       newchar.setQuestAdd(MapleQuest.getInstance(20022), (byte)1, "1");
/* 246 */       newchar.setQuestAdd(MapleQuest.getInstance(20010), (byte)1, null);
     }

/* 249 */     if (MapleCharacterUtil.canCreateChar(name, c.isGm()) && (!LoginInformationProvider.getInstance().isForbiddenName(name) || c.isGm()) && (c.isGm() || c.canMakeCharacter(c.getWorld()))) {
/* 250 */       MapleCharacter.saveNewCharToDB(newchar, jobType, subcategory, (keymode == 0));
/* 251 */       c.announce(LoginPacket.addNewCharEntry(newchar, true));
/* 252 */       c.createdChar(newchar.getId());
     } else {
/* 254 */       c.announce(LoginPacket.addNewCharEntry(newchar, false));
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\login\handler\CreateCharHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */